package day8;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class TalkClient {
    public static void main(String[] args) {
        //ip+端口
        try {
            Scanner scanner=new Scanner(System.in);
            Socket s=new Socket("192.168.10.112",8888);
            System.out.println(s+"连接成功了");
            InputStream in = s.getInputStream();
            OutputStream out = s.getOutputStream();
            BufferedReader br=new BufferedReader(new InputStreamReader(in));
            PrintWriter pw=new PrintWriter(out,true);//
            //通过控制台输入来聊天
            while (true){
                System.out.print("聊：");
                String word=scanner.next();
                pw.println(word);
                if("quit".equals(word))
                    break;
                System.out.println("等服务器回复：");
                String reply=br.readLine();
                System.out.println("服务器说："+reply);
            }
            s.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
